<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="" content="">
  <title></title>
  <style></style>
</head>

<body>
  <p>ok</p>

  <script>

    function p (url){

      return new Promise(function (resolve, reject){
        const img = document.createElement('img')
        img.src = url
        img.onload = function(){ resolve(img) }
        img.onerror = function(){ 
          //const err = new Error(`图片加载失败 ${src} `)
          const err = '图片加载失败'
          reject(err) }
      })

    }

  const url1 = "./zy/img/01.jpg"
  const url2 = "./zy/img/02.jpg"

  // p(url1).then(function(arr1){
  //   console.log(arr1)
  //   return p(url2)
  // }).then(function(arr2){
  //   console.log(arr2)
  // }).catch(function(err){ console.log(err)})

  // Promise.all([p(url1), p(url2)]).then(
  //   function(arr){
  //     let [a, b] = arr
  //     console.log(a, b)
  //   },
  //   function(err){console.log(err)}
  //   )

// ;(async function(){
//   const arr1 = await p(url1)
//   console.log(arr1)
//   const arr2 = await p(url2)
//   console.log(arr2)
// })()


  </script>
</body>

</html>